/**
 * 安卓白金英雄坛制作组 <br>
 * 文件名：EHuXiao.java <br>
 * 创建时间：2014-6-31 下午4:93:02 <br>
 * 所属项目：GmudEX <br>
 * @author ubun <br>
 */
package lostland.gmud.exv2.battle.proc.stunt;

import com.orhanobut.logger.Logger;

import lostland.gmud.exv2.Gmud;
import lostland.gmud.exv2.battle.BattleScreen;
import lostland.gmud.exv2.battle.ViewScreen;
import lostland.gmud.exv2.battle.proc.Status;
import lostland.gmud.exv2.battle.proc.StuntScreen;
import lostland.gmud.exv2.data.Npc;
import lostland.gmud.exv2.data.Room;

/**
 * 类名：EHuXiao <br>
 * 说明：40.猛虎拳·26.恶虎啸
 *
 * @author ubun
 */
public class EHuXiao extends Status {


	/**
	 * @param zdp
	 * @param bdp
	 */
	public EHuXiao(Npc zdp, Npc bdp) {
		super(zdp, bdp);
	}

	/* （非 Javadoc）
	 * @see lostland.gmud.exv2.battle.proc.Status#execute()
	 */
	@Override
	public void execute() {

		double hit_rate = 0.5 + 0.3 * (((double) zdp.getAttr(Room.ATTR_AGI) - bdp.getAttr(Room.ATTR_AGI)) / (double) (zdp.getAttr(Room.ATTR_AGI) + bdp.getAttr(Room.ATTR_AGI)));

		Logger.i("命中率=" + hit_rate);

		boolean hit = Math.random() < hit_rate;

		if (hit) {
			if (Gmud.rand.nextBoolean()) {
				new ViewScreen(BattleScreen.bsp(zdp, bdp, "这啸声中蕴有深厚内力，$n一下子被震得耳鼓生疼，头晕脑涨！")).pushToGame();
			} else {
				new ViewScreen(BattleScreen.bsp(zdp, bdp, "这啸声中蕴有深厚内力，$n被这一声吓得七窍流血，瞠目结舌！")).pushToGame();
				bdp.dmg(Math.max((int) (Math.random() * 200 + 50), bdp.getHp() - zdp.getSp()), 0);
			}
			bdp.setTransfixed(bdp.getDz() + 5);
		} else {
			new ViewScreen(BattleScreen.bsp(zdp, bdp, "可是$n内力深厚，根本就不理你什么鬼叫不鬼叫的！")).pushToGame();
			zdp.setTransfixed(zdp.getDz() + 1);
		}

		StuntScreen.StuntOver();
	}
}
